package com.tz.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * 自定义 项目名 监听器
 */
@WebListener
public class MyPathListener implements ServletContextListener {

    @Override
    public void contextInitialized(ServletContextEvent event) {
        System.out.println("tomcat启动了...");
        ServletContext application = event.getServletContext();
        String path = application.getContextPath();
        System.out.println("path:" + path);
        application.setAttribute("path", path);
    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
